package edu.zut.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 动态的解析请求路劲url
 * url属于http请求中的一部分
 * http://localhost:8080/Web201_202/showInfo   get方式
 * 环境资源：http://localhost:8080/Web201_202
 * 访问资源：/showInfo
 * 路劲信息：
 * ......
 * 请求方式：Get
 */
public class ShowInfoServlet extends HttpServlet {

    /**
     *
     * @param request 请求，http请求里面的相关内容都在这个对象里面，url属于request里面的一部分
     * @param response 响应，http响应里面的相关内容都在response里面
     * @throws ServletException
     * @throws IOException
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //协议
        String protocol = request.getProtocol();
        System.out.println("protocol = " + protocol);
        //url
        StringBuffer url = request.getRequestURL();
        System.out.println("url = " + url);
        //uri
        String uri = request.getRequestURI();
        System.out.println("uri = " + uri);
        //上下文路劲
        String contextPath = request.getContextPath();
        System.out.println("contextPath = " + contextPath);
        //请求的具体的资源路劲
        String servletPath = request.getServletPath();
        System.out.println("servletPath = " + servletPath);
        //路劲信息
        String pathInfo = request.getPathInfo();
        System.out.println("pathInfo = " + pathInfo);
        //当前请求方式
        String method = request.getMethod();
        System.out.println("method = " + method);


    }
}
